/**
 * Created by Junchuan.Wu on 2015/12/8 0008.
 */
var map = new BMap.Map("mymap");
var mPoint;
map.enableScrollWheelZoom();
var myDis =  new BMapLib.DistanceTool(map);
var geolocation = new BMap.Geolocation();
var local;
var search_nearby = document.getElementById("search_nearby");
var submit_search = document.getElementById("submit_search");
geolocation.getCurrentPosition(function(r) {
	if (this.getStatus() == BMAP_STATUS_SUCCESS) {
		var mk = new BMap.Marker(r.point);
		map.addOverlay(mk);
		map.panTo(r.point);
		map.centerAndZoom(r.point,15);
		console.log('您的位置：' + r.point.lng + ',' + r.point.lat);
		mPoint = new BMap.Point(r.point.lng , r.point.lat);  
		var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
		map.addOverlay(circle);
		local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});  
    
	} else {
		alert('failed' + this.getStatus());
	}
}, {
	enablehighaccuracy: true
});
map.addEventListener("load",function(){
		//myDis.open();  //开启鼠标测距
		myDis.close();  //关闭鼠标测距大
});
submit_search.addEventListener("click",function(){
		local.searchNearby(search_nearby.value,mPoint,1000);
},false);
